package com.hnist.empdemo.utils;

public class FunctionUtils {

    public static <T> int toInteger(Class<T> clazz, T param) {
        // 帮我实现该函数
        if (param == null) {
            return 0;
        }

        if (param instanceof Number) {
            return ((Number) param).intValue();
        }

        if (param instanceof String) {
            try {
                return Integer.parseInt((String) param);
            } catch (NumberFormatException e) {
                return 0;
            }
        }
        return 0;
    }

}
